<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="入库时间">
              <j-date placeholder="请选择入库时间" style="width: 100%" v-model="queryParam.begindate"></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单编号">
              <a-input placeholder="请输入订单编号" v-model="queryParam.attr1"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a-button @click="print" type="primary" style="margin-left: 8px">打印</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
 <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls3('入库单')">导出</a-button>
    </div>
    <!-- table区域-begin -->
    <div>
      <!--<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
      <!--<i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项-->
      <!--<a style="margin-left: 24px" @click="onClearSelected">清空</a>-->
      <!--</div>-->
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{ x: 1500,y: 600  }"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">查看</a>
          <!--<a @click="handleEdit(record)">编辑</a>-->

          <!--<a-divider type="vertical" />-->
          <!--<a-dropdown>-->
          <!--<a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
          <!--<a-menu slot="overlay">-->
          <!--<a-menu-item>-->
          <!--<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
          <!--<a>删除</a>-->
          <!--</a-popconfirm>-->
          <!--</a-menu-item>-->
          <!--</a-menu>-->
          <!--</a-dropdown>-->
        </span>

      </a-table>
    </div>
    <a-modal v-model="visibleDetail" title="原材料入库单" @ok="visibleDetail = false" width="90%" :footer="null">
      <RawMaterialStorage :total1="total1" :total2="total2" :reportData="printData"/>
    </a-modal>
  </a-card>
</template>

<script>

import { httpAction, getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import '@/assets/less/TableExpand.less'
import JDate from '@/components/jeecg/JDate.vue'
import RawMaterialStorage from '@views/inspect/RawMaterialStorage'

export default {
  name: 'RkdList',
  mixins: [JeecgListMixin],
  components: {
    JDate,
    RawMaterialStorage
  },
  data() {
    return {
      total1:0,
      total2:0,
      printData:[],
      visibleDetail:false,
      instrlist: {},
      description: '入库单',
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '订单编号',
          align: 'center',
          dataIndex: 'attr1'
        },
        {
          title: '料号',
          align: 'center',
          dataIndex: 'attr2'
        },
        {
          title: '客户料号',
          align: 'center',
          dataIndex: 'attr3'
        },
        {
          title: '名称',
          align: 'center',
          dataIndex: 'attr4'
        },
        {
          title: '规格',
          align: 'center',
          dataIndex: 'attr5'
        },
        {
          title: '伏数',
          align: 'center',
          dataIndex: 'attr6'
        },
        {
          title: '误差',
          align: 'center',
          dataIndex: 'attr7'
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'attr8'
        },
        {
          title: '申购数量',
          align: 'center',
          dataIndex: 'attr9'
        },
        {
          title: '实收数量',
          align: 'center',
          dataIndex: 'attr10'
        },
        {
          title: '入库数量',
          align: 'center',
          dataIndex: 'attr13'
        },
        {
          title: '日期',
          align: 'center',
          dataIndex: 'attr11'
        },
        {
          title: '供应商',
          align: 'center',
          dataIndex: 'attr12'
        },
        {
          title: '区域编码',
          align: 'center',
          dataIndex: 'attr14'
        },
        {
          title: '位置编码',
          align: 'center',
          dataIndex: 'attr15'
        }
      ],
      url: {
        list: '/storage/reportapi/selectYclRkd',
        exportXlsUrl: "/storage/reportapi/exportYclRkd",
      },
      dictOptions: {}
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    initDictConfig() {

    },
    print(){
      this.total1 = 0
      this.total2 = 0
      this.printData = this.selectionRows
      this.printData.forEach(item=>{
        this.total1 += Number(item.attr9)
        this.total2 += Number(item.attr10)
      })
      this.visibleDetail = true
      console.log(11,this.printData)
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
